//888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
//
//	File		 :	batch_job.h
//	Contents	 :	Header file for handling batch jobs
//	Creation Date:	18/02/2004
//	Last Modified:	18/02/2004	lg
//	tabs width	 :	every 4 characters
//
//888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

#if !defined(BATCH_JOB_H)
#define BATCH_JOB_H

#include <deque>
#include <iostream>
#include <string>
#include "pg_db_cursor.h"


struct t_gi_pair
{
	std::string gene_id1;
	std::string gene_id2;
	t_gi_pair(const std::string& g1, const std::string& g2) : gene_id1(g1), gene_id2(g2){}
};
typedef std::deque<t_gi_pair> t_gi_pairs;

class t_batch_num
{
	t_pg_cursor&	pg_db;
	bool			committed;
	std::string		job_category;
	std::string		batch_num_txt;
	bool			try_get_next(const std::string& job_category_);
	bool			try_get(const std::string& job_category_, unsigned batch_num);
public:
	const std::string& text() const;
					t_batch_num(t_pg_cursor& pgdb);
	bool			get_next(const std::string& job_category);
	bool			get(const std::string& job_category, unsigned batch_num);
	bool			get_gene_pairs(	t_gi_pairs& gi_pairs, std::ostream& err_strm);
	void 			commit();
	void			free_hanging_jobs();
};

std::string get_backend_pid(t_pg_cursor& pg_db);
#endif	//BATCH_JOB_H

